<?php

namespace app\models;

use yii;
use yii\db\Query;


class Broadcast
{
    private $table;

    public function __construct()
    {
        $this->table = yii::$app->db->tablePrefix . 'broadcast';
    }

    /**插入数据
     * @param $data
     * @return int|string
     */
    public function insert($data)
    {
        try {
            return yii::$app->db->createCommand()->insert($this->table, $data)->execute();
        } catch (\Exception $e) {
            return false;
        }
    }

    /**获取组的广播
     * @param array $group
     * @return array
     */
    public function get_broadcast_by_group($group)
    {
        $db = new Query();
        return $db->select('*')->from($this->table)->where(['in', 'group_id', $group])->all();
    }
}